package net.bingosoft.common.util;

import java.util.ArrayList;
/**
 * 2007-8-29 下午03:29:26
 * Author:yangdongyu(yangdy@bingosoft.net)
 * ReadMe:能够自动初始化的列表实现
 * ChangeLog:添加对泛型的支持
 */
public class AutoArrayList<T> extends ArrayList<T> {

	private static final long serialVersionUID = 1L;
	private Class<T> itemClass;
	
	public AutoArrayList(Class<T> itemClass) {
		this.itemClass = itemClass;
	}
	@Override
	public T get(int index) {
		try {
			while (index >= size()) {
				add(itemClass.newInstance());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return super.get(index);
	}	
}

